
package com.wyzz.hr.bo.impl;

import com.wyzz.hr.bo.IEmpRelationsBo;
import com.wyzz.hr.dao.IEmpRelationsDao;
import com.wyzz.hr.pojo.Employee;
import com.wyzz.hr.pojo.Emprelations;

import java.util.List;
import org.hibernate.FetchMode;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;


public class EmpRelationsBoImpl implements IEmpRelationsBo {

	public EmpRelationsBoImpl() {
	}

	public String insert(Emprelations empRelations) {
		empRelationsDao.saveObject(empRelations);
		return empRelations.getErelId();
	}

	public List search(String employeeId) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Emprelations.class);
		detachedCriteria.setFetchMode(Emprelations.PROP_EREL_EMPLOYEE,
				FetchMode.DEFAULT);
		detachedCriteria.add(Restrictions.eq((new StringBuilder()).append(
				Emprelations.PROP_EREL_EMPLOYEE).append(".").append(
				Employee.PROP_ID).toString(), employeeId));
		List result = empRelationsDao.findByCriteria(detachedCriteria);
		return result;
	}

	public void delete(Emprelations erel) {
		empRelationsDao.deleteObject(erel);
	}

	public void update(Emprelations empRelations) {
		empRelationsDao.updateObject(empRelations);
	}

	public List search(Emprelations empRelations) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Emprelations.class);
		detachedCriteria.setFetchMode(Emprelations.PROP_EREL_EMPLOYEE,
				FetchMode.DEFAULT);
		detachedCriteria.add(Restrictions.eq(Emprelations.PROP_EREL_ERELID,
				empRelations.getErelId()));
		List empRelationsObj = empRelationsDao.findByCriteria(detachedCriteria);
		return empRelationsObj;
	}

	public IEmpRelationsDao getEmpRelationsDao() {
		return empRelationsDao;
	}

	public void setEmpRelationsDao(IEmpRelationsDao empRelationsDao) {
		this.empRelationsDao = empRelationsDao;
	}

	public Emprelations load(String ehrId, String fetches[]) {
		return (Emprelations) empRelationsDao.loadObject(
				com.wyzz.hr.pojo.Emprelations.class, ehrId, fetches,
				new boolean[0]);
	}

	private IEmpRelationsDao empRelationsDao;
}
